import axios from 'axios'

interface resultData {
  data: any
  success: boolean
  errMsg?: string
}
interface responseData {
  data: {
    data: responseData
  }
}

const instance = axios.create({
  baseURL: '/'
})

instance.interceptors.request.use((config) => {
  config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  return config
})

instance.interceptors.response.use((response) => {
  return response.data
})

function get(url: string, data: any, headers?: object) {
  return instance({ method: 'get', url, params: data, headers })
}
function post(url: string, data: any, headers?: object) {
  return instance({ method: 'post', url, data, headers })
}

export { get, post }
